<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div style="text-align: center;">
        <select name="" id="se1">
            <option value="">选择大小</option>
            <option value="大">选大</option>
            <option value="小">选小</option>
        </select>
        <br />
        <br />
        <img src="../定时器作业/摇色子/1.jpg" alt="" width="110px" height="110px" id="imgid">
        <br />
        <input type="button" value="开始" onclick="cliall()">
    </div>

</body>
    <script>
        var seobj=document.getElementById('se1');
        function cliall(){
           // event.target.value='开始循环';
           var ii=0;
            if (seobj.value=='') {
                alert('请下注!!');
                return false;
            }
            var temp=setInterval(function(){
                var imgobj=document.getElementById('imgid');
                var k=inter();
                console.log('输出点数'+k);
                var str='../定时器作业/摇色子/'+k+'.jpg'
                imgobj.src=str;
                ii++;
                if(ii>20){
                    clearInterval(temp);
                    aa(k);
                }
            },150);
        };
        function inter(){
            while(true){
                var i=Math.ceil(Math.random()*6)
                if (i!==0) {
                    return i;
                }
            }
        }
        function aa(k){
           // var seobj=document.getElementById('se1');
            if (seobj.value=='大') {
                if (k>3) {
                    alert('你赢了！');
                }else{
                    alert('完蛋没钱了！');
                }
            }else if (seobj.value=='小') {
                if (k<4) {
                    alert('你赢了！');
                }else{
                    alert('完蛋没钱了！');
                }
            }
        }
    </script>
</html>